If r <> 0 Then MsgBox "INFOLINK.DLL was not able to release memory used for decompression. Some Windows resources may be lost. You may want to restart Windows.", 48, "Error in unloading"
r = CloseIndex(IndexId)
If r <> 0 Then MsgBox "INFOLINK.DLL was not able to Close the Cookbook index. You may want to restart Windows.", 48, "Error in unloading"
r = CloseInfoLink()
If r <> 0 Then MsgBox "INFOLINK.DLL was not able to shut down properly. You may want to restart windows to release trapped resources.", 48, "Error in unloading"
'Set the searchexp to UPPERCASE, and verify parentheses
SearchExp$ = UCase$(Trim$(SearchExp$))
If Right$(SearchExp$, 1) = "&" Then SearchExp$ = Trim$(Left$(SearchExp$, Len(SearchExp$) - 1))
LPCount = 0
RPCount = 0
For x = 1 To Len(SearchExp$)
If Mid$(SearchExp$, x, 1) = "(" Then LPCount = LPCount + 1
If Mid$(SearchExp$, x, 1) = ")" Then RPCount = RPCount + 1
Next x
If LPCount <> RPCount Then
x = 0
Do
x = x + 1
If x > Len(SearchExp$) Then Exit Do
If Mid$(SearchExp$, x, 1) = "(" Or Mid$(SearchExp$, x, 1) = ")" Then
SearchExp$ = Left$(SearchExp$, x - 1) & Mid$(SearchExp$, x + 1)
End If
Loop
x = MsgBox("Your parentheses are not paired equally. They have been removed. " & Chr$(10) & "Do you still wish to search?", 49, "Unmatched Parentheses")
If x = 2 Then Exit Sub '1 = MB_OKCANCEL
End If
If TRListID <> 0 Then
x = CloseTRList(TRListID)
End If
SearchExp$ = SearchExp$ & Chr$(0)
x = ExpressionSearch(SearchExp$)
'BLTId must be set to reflect the TRList that is open.
' otherwise, it will be left at 1, and the chapter
' headings will reflect 1,094,000 recipes!
BLTId = Popstack()
x = Pushstack(BLTId)
TRListID = OpenTRList()
x = LastResultTRCount(RecipesFound)
x = GetNextTRNumber(TRListID, TRNumber)
cmdSearch.Enabled = True
cmdClear.Enabled = True
cmdExit.Enabled = True
frmPleaseWait.Hide
MakeMouseCursorDefault
If RecipesFound = 0 Then
MsgBox "No recipes match search."
Else
If RecipesFound > FirstRecordInBook(53) Then RecipesFound = FirstRecordInBook(53)